<template>
	<div class="table" style="margin-top:10px;">
		<a-tabs :defaultActiveKey="userType" @change="callback">
			<a-tab-pane v-for="(item,i) in userTypeList" :key="item.Key" :tab="item.Value"></a-tab-pane>
		</a-tabs>
		<el-table :data="data" v-loading="loading" border :max-height="tableHeight" highlight-current-row style="width: 100%;">
			<el-table-column type="index" label="序号" width="60"></el-table-column>
			<el-table-column prop="UserNo" label="学号" width="110"></el-table-column>
			<el-table-column prop="Name" label="姓名" width="130"></el-table-column>
			<el-table-column prop="TypeName" label="类型" width="130"></el-table-column>
			<el-table-column prop="TypeName" label="学院/班级" min-width="140">
				<template slot-scope="scope">
					{{ scope.row.DepartName }} / {{ scope.row.ClassName }}
				</template>
			</el-table-column>
			<el-table-column prop="Score" label="学分" width="90"></el-table-column>
			<el-table-column prop="IsSign" label="签到类型" width="90">
				<template slot-scope="scope">
					{{ scope.row.IsSign?'已签到':'未签到' }}
				</template>
			</el-table-column>
			<el-table-column prop="AddTime" label="时间" width="140"></el-table-column>
			<el-table-column label="操作" width="90" fixed="right">
				<template slot-scope="scope">
					<oprateBtn title="删除" v-if="$route.query.type!=2" icon="icon-delete" color="red" @tap="deleteList(scope.row)"></oprateBtn>
				</template>
			</el-table-column>
		</el-table>
		<el-pagination
			@size-change="handleSizeChange"
			@current-change="handleCurrentChange"
			:current-page="pagination.currentPage"
			:page-sizes="pagination.pageSizeOptions"
			:page-size="pagination.pageSize"
			layout="total, sizes, prev, pager, next, jumper"
			:total="pagination.total"
		></el-pagination>
	</div>
</template>

<script>
import moment from 'moment';
import Func from '@/utils/func';
import Cache from '@/utils/cache';
import { ManageActivityFlowDoGetMemberPageList,ManageActivityFlowDoDeleteMember } from '@/api/follow';
const data = [];
export default {
	components: {
	},
	data() {
		return {
			data,
			loading: false,
			pagination: {
				currentPage: 1,
				pageSize: this.global.pageSize,
				pageSizeOptions: this.global.pageSizeOptions, // 每页中显示的数据
				showTotal: total => `共有 ${total} 条数据` // 分页中显示总的数据
			},
			tableHeight: parseFloat(window.innerHeight - 160),
			requestUrl:this.global.requestUrl,
			token:Cache.get('token'),
			userType:0,
			userTypeList:this.global.userTypeList
		};
	},
	created() {
		this.getList();
	},
	mounted() {},
	methods: {
		moment,
		callback(key){
			this.userType = key
			this.pagination.currentPage = 1
			this.getList()
		},
		handleSizeChange(val) {
			this.pagination.pageSize = val;
			this.getList();
		},
		handleCurrentChange(val) {
			this.pagination.currentPage = val;
			this.getList();
		},
		async getList() {
			this.loading = true;
			let data = {};
			data.id = this.$route.query.ID
			data.pageIndex = this.pagination.currentPage;
			data.pageSize = this.pagination.pageSize;
			data.type = this.userType==0?'':this.userType
			let res = await ManageActivityFlowDoGetMemberPageList(data);
			if(res.data.code!==0){
				this.$message.error(res.data.msg)
			}
			this.loading = false;
			this.data = res.data.data;
			const pagination = { ...this.pagination };
			pagination.total = res.data.pageInfo.TotalItemCount;
			this.pagination = pagination;
		},
		deleteList(text) {
			let that = this;
			this.$confirm({
				title: '提示',
				content: `您确定删除该数据吗？`,
				okText: '确认',
				cancelText: '取消',
				async onOk() {
					let data = {};
					data.memberID = text.ID;
					let res = await ManageActivityFlowDoDeleteMember(data);
					if (res.data.code == 0) {
						that.getList();
						that.$message.success(res.data.msg);
					} else {
						that.$message.error(res.data.msg);
					}
				}
			});
		},
	}
};
</script>

<style lang="less" scoped>
/deep/.ant-form-item {
	display: flex;
	margin-bottom: 10px !important;
}
/deep/.ant-form-item-label {
	width: 80px;
	overflow: hidden;
	white-space: nowrap;
	text-overflow: ellipsis;
	text-align: right;
}
/deep/.ant-form-item-control-wrapper {
	flex: 1;
}
/deep/.el-table th.is-leaf {
	background: #fafafa;
}
/deep/.el-table td,
/deep/.el-table th {
	padding: 5px;
}
.option {
	margin-top: 10px;
	margin-bottom: 20px;
	overflow: hidden;
}
.option .btn {
	height: 36px;
	line-height: 36px;
	padding: 0 10px;
	float: left;
	background: #1890ff;
	color: #fff;
	margin-right: 10px;
	border-radius: 3px;
	cursor: pointer;
	border: none;
}
.foot {
	text-align: center;
	margin-top: 100px;
}
.el-pagination {
	margin-top: 10px;
}
</style>
